// ---------------------------
// 扩展模块：多语言支持

import { ResLoader } from "../ResLoader";

// ---------------------------
export class Localization {
    private static texts: Map<string, string> = new Map();
    private static currentLanguage = 'en';

    // 初始化语言
    public static async init(language: string = 'en'): Promise<void> {
        this.currentLanguage = language;
        await this.loadLanguageData(language);
    }

    // 加载语言数据
    private static async loadLanguageData(language: string): Promise<void> {
        let data = await ResLoader.loadJson(language, 'lang');
        if (data) {
            this.texts = new Map((Object as any).entries(data));
        }
    }


    // 获取本地化文本
    public static getText(key: string, defaultValue: string = ''): string {
        return this.texts.get(key) || defaultValue;
    }

    // 更新UI文本
    public static updateUITexts(): void {
        // 查找所有带LocalizedText组件的节点
        // 并更新文本内容
    }
}